import { ref } from 'vue'
import PageContent from '@/components/page-content'

export const usePageSearch = () => {
  const pageContentRef = ref<InstanceType<typeof PageContent>>()
  const handleQueryClick = (queryInfo: any) => {
    Object.keys(queryInfo).map((key) => {
      if (queryInfo[key] === '') {
        delete queryInfo[key]
      }
    })
    if (JSON.stringify(queryInfo) == '{}') {
      queryInfo.flag = 'o'
    } else {
      queryInfo.flag = 'l'
    }
    console.log('kkkkkkkkkk', { ...queryInfo })
    pageContentRef.value?.getPageData(queryInfo)
  }
  const handleResetClick = () => {
    pageContentRef.value?.getPageData()
  }

  return [pageContentRef, handleQueryClick, handleResetClick]
}
